package com.usian.search.controller;

import com.usian.apis.article.ArticleInfoControllerApi;
import com.usian.apis.search.ArticleSearchControllerApi;
import com.usian.model.common.dtos.ResponseResult;
import com.usian.model.user.dtos.UserSearchDto;
import com.usian.search.service.ApArticleSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/api/v1/article/search")
public class ArticleSearchController  implements ArticleSearchControllerApi {

    @Autowired
    private ApArticleSearchService apArticleSearchService;


    @Override
    @RequestMapping("/search")
    public ResponseResult search(@RequestBody UserSearchDto userSearchDto) {

        try {
            ResponseResult search = apArticleSearchService.search(userSearchDto);
            return search;
        } catch (IOException e) {
            e.printStackTrace();
        }
        return ResponseResult.errorResult(10000,"查询异常");
    }
}
